﻿using System.Windows;
using System.Windows.Media;

namespace FAQ_UI
{
	internal class RoundDrawable : Drawable, Drawable.InvalidateListener
	{
		public EllipseGeometry geometry;
		private Drawable mDrawable;

		public RoundDrawable(Drawable drawable)
		{
			this.mDrawable = drawable;
			mDrawable.setInvalidateListener(this);
		}

		protected override void onBoundsChange(Rect oldBounds, Rect newBounds)
		{
			geometry = new EllipseGeometry(newBounds);
			mDrawable.setBounds(newBounds);
		}

		public override void draw(DrawingContext canvas)
		{
			canvas.PushClip(geometry);
			mDrawable.draw(canvas);
		}

		public void drawableInvalidate()
		{
			invalidateSelf();
		}
	}
}